/**
 * Copyright (c) 华南农业大学信息学院蔡超敏2015版权所有
 * 
 * 文件创建时间：2015年7月2日
 */
package org.scauinfo.fpos.service.impl;

import java.io.Serializable;
import java.util.List;

import org.scauinfo.fpos.dao.impl.ResourceDao;
import org.scauinfo.fpos.service.ResourceService;
import org.scauinfo.fpos.vo.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 蔡超敏
 *
 */
@Service
public class ResourceServiceImpl implements ResourceService{
	@Autowired
	private ResourceDao resourceDao;

	@Override
	public void saveResource(Resource resource) {
		resourceDao.save(resource);
	}

	@Override
	public void updateResource(Resource resource) {
		resourceDao.update(resource);
	}

	@Override
	public void deleteResource(int id) {
		Resource resource = resourceDao.get(id);
		resourceDao.delete(resource);
	}

	@Override
	public List<Resource> findAllResource(int page, int rows, String sort,
			String order) {
		return resourceDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		return resourceDao.countAll();
	}

	@Override
	public boolean isExist(String resourceId) {
		boolean flag = false;
		String hql = "from Resource as p where p.resourceId=" + resourceId;
		if (resourceDao.find(hql).size() > 0) {
			flag = true;
		}
		return flag;
	}

	@Override
	public Resource get(Serializable id) {
		return resourceDao.get(id);
	}

	@Override
	public List<Resource> findAllResource() {
		return resourceDao.findAll();
	}
}